# -*- coding: utf-8 -*-

from db import *

class WizData(object):
  
  class __Data:
    def __init__(self):
      
      self.excelfile = ExcelFile()
      self.map = Mapping()
      
      """ file info """
      # ##################################################
      self.filename = None   # excel file name
      self.pstart = None    # company name
      self.pend = None       # period of the payment
      self.period = 0
      self.inout = None
      
      # ##################################################
      """ mapping info """
      self.mapping_id = None
      #self.mapping = None    # mapping
      self.col_list = ""
      self.colline = None    #
      self.datarows = None   #
      self.ignore_last = None    # moved ?
      
      # ##################################################
      
      self.key_col = None
      self.list = None      # list ?? mapping ??
      self.mapping = None
      self.map_name = ''
      self.mappingtype = u'工资表'
      self.col_set = None
      
      # ##################################################
      self.colcat = None     # column category 
      self.selmap = ''       #
      self.newmap = 0        #
      self.lastline = 0      # ignore last lines of the excel file
      
      # ##################################################
      
      self.map_uid = ""
      self.labels = []
      self.rowstart = None   # line start 
      self.colstart = None   # col start
      self.nrows = None
      self.ncols = None
      self.exceldata = None  # ((),())
      
      self.dir = None
      self.newcol = []
      self.newcollist = []
      
      self.option = 0
      
      
    """
    def setmapping(self,k,v):
      self.mapping[k]=v
    """
  instance = None
  
  def __new__(cls):
    if not WizData.instance:
      WizData.instance =WizData.__Data()              
    return WizData.instance
  

  
  def __getattr__(self, name):
    return getattr(self.instance, name)
    
  def __setattr__(self, name):
    return setattr(self.instance, name)    


def test():
  data = WizData()
  #print data
  data.file ="it'myfile"
  #data.setfile('my - file')
  dat = WizData()
  dat.company = 'aidear'
  #print dat
  print dat.excelfile
  print data.company
 


if __name__ == "__main__":
    test()
